package com.bba.manager.order.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bba.manager.common.model.order.PurchaseDetails;
import com.bba.manager.order.mapper.PurchaseDetailsMapper;
import com.bba.manager.order.service.IPurchaseDetailsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 采购详情表 服务实现类
 * </p>
 *
 * @author zzy
 * @since 2025-08-12
 */
@Service
public class PurchaseDetailsServiceImpl extends ServiceImpl<PurchaseDetailsMapper, PurchaseDetails> implements IPurchaseDetailsService {

    @Override
    public List<PurchaseDetails> selectByPurchaseId(Long purchaseId) {
        LambdaQueryChainWrapper<PurchaseDetails> wrapper = new LambdaQueryChainWrapper<>(this.getBaseMapper());
        return wrapper.eq(PurchaseDetails::getPurchaseNo,purchaseId).list();

    }

    @Override
    public void deletedByPurchaseId(Long purchaseId) {
        LambdaQueryWrapper<PurchaseDetails> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PurchaseDetails::getPurchaseNo, purchaseId);
        this.remove(wrapper); // 按条件直接删除
    }


}
